{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "abe44b51",
   "metadata": {},
   "source": [
    "日期：2022-10-12\\week8\n",
    "\n",
    "课程：python"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0b814bff",
   "metadata": {},
   "source": [
    "# 本周知识点"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b639dbf2",
   "metadata": {},
   "source": [
    "1.字符串的性质和方法\n",
    ">1.字符串有序性\n",
    "\n",
    ">2..字符串是有长度的\n",
    "\n",
    ">>1.使用len（）检查字符串的长度\n",
    "\n",
    "* 字符串的基础方法\n",
    ">字符串的取值:str[index]\n",
    ">2.字符串的切片：str[start,stop],stop"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "bc40ef54",
   "metadata": {},
   "outputs": [],
   "source": [
    "text =\"广州南方学院团委\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a465e714",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ed55f21f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'州'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "01e78208",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'委'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1de091fe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'团'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[-2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "1f327460",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "string index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [6]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mtext\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m100\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "\u001b[1;31mIndexError\u001b[0m: string index out of range"
     ]
    }
   ],
   "source": [
    "text[100]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "b61aabb0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "219166b7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[0] + text[1] + text[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "3791a9f2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[0:6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "d4af1dc0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[ :6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "3234bef2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[-1:-3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "5a4e8bee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'院团'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[-3:-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "0fa7d3bc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'团委'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[-2: ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "0d779028",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院团委广州南方学院团委广州南方学院团委'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3 * text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "1211a735",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (809133313.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [19]\u001b[1;36m\u001b[0m\n\u001b[1;33m    * in 检查成员对像\u001b[0m\n\u001b[1;37m      ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "* in 检查成员对像\n",
    "*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "95761773",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"广州\" in text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "51f95384",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"北京\" in text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "395e3e47",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3 * text.count(\"广州\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "91cd2048",
   "metadata": {},
   "outputs": [],
   "source": [
    "age_1 = 19"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
